package com.zbkj.crmeb.store.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.crmeb.core.common.CommonResult;
import com.common.PageParamRequest;
import com.crmeb.core.exception.CrmebException;
import com.zbkj.crmeb.chant.model.ChannelMerchant;
import com.zbkj.crmeb.export.vo.DeliveryOrderBatchVo;
import com.zbkj.crmeb.export.vo.StoreOrderExcelVo;
import com.zbkj.crmeb.express.vo.LogisticsResultVo;
import com.zbkj.crmeb.order.request.JkyItemSynRequest;
import com.zbkj.crmeb.order.request.OutOrderRequest;
import com.zbkj.crmeb.order.request.TmallOrderInfoRequest;
import com.zbkj.crmeb.order.request.TmallStoreOrderRequest;
import com.zbkj.crmeb.store.model.OrderInfoDeliveryBatchUpload;
import com.zbkj.crmeb.store.model.StoreOrder;
import com.zbkj.crmeb.store.request.*;
import com.zbkj.crmeb.store.response.RetailShopOrderDataResponse;
import com.zbkj.crmeb.store.response.StoreOrderInfoResponse;
import com.zbkj.crmeb.store.response.StoreOrderResponse;
import com.zbkj.crmeb.store.response.SupplierOrderResponse;
import com.zbkj.crmeb.system.model.SystemAdmin;
import com.zbkj.crmeb.system.request.SystemWriteOffOrderSearchRequest;
import com.zbkj.crmeb.system.response.SystemWriteOffOrderResponse;
import com.zbkj.crmeb.user.model.User;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Transactional;

/**
* @author Mr.Zhang
* @description StoreOrderService 接口
* @date 2020-05-28
*/
public interface StoreOrderService extends IService<StoreOrder> {
    /**
     * 订单id查询订单信息
     * @param orderId
     * @return
     */
    StoreOrder getByOrderId(String orderId);

    List<StoreOrder> getByOrderIds(List<String> orderIds);

    List<StoreOrder> getList(StoreOrderSearchRequest request, PageParamRequest pageParamRequest);

    StoreOrderResponse getAdminList(StoreOrderSearchRequest request, PageParamRequest pageParamRequest,SystemAdmin systemAdmin);

    StoreOrderResponse getPickingList(StoreOrderSearchRequest request, PageParamRequest pageParamRequest,SystemAdmin systemAdmin);

    void getStoreOrderListRequest(StoreOrderSearchRequest request,SystemAdmin systemAdmin );

    SystemWriteOffOrderResponse getWriteOffList(SystemWriteOffOrderSearchRequest request, PageParamRequest pageParamRequest);

    BigDecimal getSumBigDecimal(Integer userId, String date);

    Map<Integer, StoreOrder> getMapInId(List<Integer> orderIdList);

    /**
     * H5订单列表
     * @param storeOrder 查询参数
     * @param pageParamRequest 分页参数
     * @return 订单结果列表
     */
    List<StoreOrder> getUserOrderList(StoreOrder storeOrder, PageParamRequest pageParamRequest);
    /**
     * 创建订单
     * @param storeOrder 订单参数
     * @return 创建结果
     */
    boolean create(StoreOrder storeOrder);

    /**
     *  根据参数直接下单
     * @param userId 用户id
     * @param productId 产品id
     * @param cartNum 商品数量
     * @param productAttrUnique 商品唯一标识
     * @param type 商品默认类型
     * @param isNew isNew
     * @param combinationId 拼团id
     * @param skillId 秒杀id
     * @param bargainId 砍价id
     * @return 是否成功下单
     */
    List<String> addCartAgain(Integer userId, Integer productId, Integer cartNum, String productAttrUnique, String type,
                              boolean isNew, Integer combinationId, Integer skillId, Integer bargainId);

    /**
     * 订单基本查询
     * @param storeOrder 订单参数
     * @return 订单查询结果
     */
    List<StoreOrder> getByEntity(StoreOrder storeOrder);

    /**
     * 根据属性仅仅获取一条
     * @param storeOrder 参数
     * @return 当前查询结果
     */
    StoreOrder getByEntityOne(StoreOrder storeOrder);

    /**
     * 基本更新
     * @param storeOrder 更新参数
     * @return 更新结果
     */
    boolean updateByEntity(StoreOrder storeOrder);

    /**
     * 余额支付
     * @param storeOrder 待支付订单
     * @param currentUser 当前用户
     * @param
     * @return 支付结果
     */
    boolean yuePay(StoreOrder storeOrder, User currentUser);

    /**
     * h5 top data 工具方法
     * @param status 状态参数
     * @return 查询到的订单结果
     */
    List<StoreOrder> getTopDataUtil(int status, int userId);

    int getOrderCount(Integer userId, String date);

    List<StoreOrder> getOrderGroupByDate(String dateLimit, int lefTime);

    boolean refund(StoreOrderRefundRequest request);

    boolean refundTest(StoreOrderRefundRequest request);

    boolean refundGoods(RefundGoodsRequest request);

    StoreOrderInfoResponse info(Integer id);
    
    Boolean pushOrder(PushOrderRequest pushOrderRequest, String ip, SystemAdmin systemAdmin);
    
    Boolean pushOrderJky(Integer orderId, String ip, SystemAdmin systemAdmin);
    
    Boolean pushOrderWzbsc(List<KaiCangOrderRequest> kaiCangOrderRequest);
    
    Boolean pushOrderCainiao(List<CainiaoOrderRequest> orderRequest);

    boolean send(StoreOrderSendRequest request);

    boolean mark(Integer id, String mark);

    boolean refundRefuse(Integer id, String reason);

    RetailShopOrderDataResponse getOrderDataByUserId(Integer userId);

    List<StoreOrder> getOrderByUserIdsForRetailShop(List<Integer> ids);

    StoreOrder getInfoByEntity(StoreOrder storeOrder);

    /**
     * 根据条件获取
     * @param storeOrder 订单条件
     * @return 结果
     */
    StoreOrder getInfoJustOrderInfo(StoreOrder storeOrder);

    LogisticsResultVo getLogisticsInfo(Integer id);
    
    /**
     * 跨境商品支付单报关(微信)
     * @param infoIds
     * @return
     */
    String pushWxCustoms(List<Integer> infoIds);
    
    /**
     * 跨境商品支付单报关(汇付)
     * @author daigb
     * @date:  2022-08-01 10:27
     */
    String pushAdapayCustoms(List<Integer> infoIds);

    /**
     * 跨境商品支付单报关(连连)
     * @author daigb
     * @date:  2022-08-01 10:27
     */
    String pushLianlianCustoms(List<Integer> infoIds);

    Map<String, String> getStatus(StoreOrder storeOrder);

    List<String> queryOrderIds(Date startTime);

    void push(TmallStoreOrderRequest order, List<TmallOrderInfoRequest> orderInfoRequestList);
    
    /**
     * 外部订单推送
     * @Description:  
     * @author daigb 
     * @param @param outOrderRequest
     * @param @return
     * @return Boolean
     * @throws
     */
    Boolean pushOutOrder(OutOrderRequest outOrderRequest, ChannelMerchant channelMerchant);

    Boolean CheckJkyItemSyn(JkyItemSynRequest jkyItemSynRequest);

    Boolean jkyCancelOrder(Integer id);

    List<StoreOrderExcelVo> getExportList(StoreOrderSearchRequest request, PageParamRequest pageParamRequest,SystemAdmin systemAdmin);

    void updateUserIntegral(StoreOrder storeOrder,User currentUser);

    void cancelUserIntegral(StoreOrder storeOrder, User currentUser,String mesg);

    CommonResult<Object> getSupplierOrderInfoById(Integer id);

    /**
     * 子订单确认订单
     * @param id
     * @return
     */
    boolean confirmChildOrder(Integer id, String remark,Integer actualSupplierId,BigDecimal actualCost,BigDecimal actualCostEur, Integer stockAreaCode,SystemAdmin systemAdmin);

    /**
     * 修改用户地址
     * @param request
     * @return
     */
    boolean updateUserAddress(UpdateUserAddressRequest request);

    /**
     * 确认收货（完成订单）
     * @param id  orderInfoId
     * @param reason
     * @return
     */
    boolean confirmReceipt(Integer id, String reason);

    /**
     * 确认收货（完成订单）
     * @param storeOrderRequest
     * @return
     */
    boolean confirmReceiptManually(StoreOrderRequest storeOrderRequest);

    /**
     * 取消订单
     * @param id
     * @return
     */
    boolean cancel(Integer id);

    List<StoreOrder> userAndOrderInfoList(QueryWrapper<StoreOrder> queryWrapper);

    /**
     * 添加运税费
     * @param request
     * @return
     */
    boolean addActualTaxAndSecondPrice(StoreOrderInfoTaxPriceRequest request);

    /**
     * 使用平台物流
     * @param id orderInfoId
     * @return
     */
    boolean useSystemDelivery(Integer id);

    List<StoreOrder> getBacklogOrderQuantity();

    boolean note(Integer id, String note);

    boolean refundApply(Integer id);

    boolean refundApplyCancel(Integer id);

    boolean confirmReceiptSupplier(Integer id, String reason);

    boolean cancelReceiptSupplier(Integer id, String clientIp);

    boolean cancelReceiptSupplierByApi(Integer id, String clientIp);

    void SeatentRefund();

    /**
     * 功能描述: 批量发货
     * @Param: [request]
     * @Return: boolean
     * @Author: wangzh
     * @Date: 2023/3/29 14:57
     */
    OrderInfoDeliveryBatchUpload deliveryOrderBatch(List<DeliveryOrderBatchVo> request);

    /**
     * 功能描述: 溯源订单推送
     * @Param: [request]
     * @Return: boolean
     * @Author:
     * @Date: 2023/4/12
     */
    Boolean pushOrderTS(PushOrderRequest pushOrderRequest);

    Boolean isAllConfirm(StoreOrder storeOrder,Integer status);

    /**
     * 功能描述: 变更供应商
     * @Param: [id, remark, actualSupplierId, actualCost, actualCostEur, stockAreaCode]
     * @Return: java.lang.Boolean
     * @Author: wangzh
     * @Date: 2023/5/22 14:27
     */
    Boolean changeSupplier(Integer id, String remark, Integer actualSupplierId, BigDecimal actualCost, BigDecimal actualCostEur, Integer stockAreaCode);
}
